package com.njym.java.security.app.rest;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.njym.java.security.app.biz.FamilyNewsBiz;
import com.njym.java.security.app.entity.FamilyNews;
import com.njym.java.security.common.msg.TableResultResponse;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

@Controller
@RequestMapping("familyNews")
public class FamilyNewsController extends BaseController<FamilyNewsBiz,FamilyNews> {
        @RequestMapping(value = "/lists",method = RequestMethod.GET)
        @ResponseBody
        public TableResultResponse<Object> lists(@RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1")int page){

            Example example = new Example(FamilyNews.class);
            Page<Object> result = PageHelper.startPage(page, limit);
            example.createCriteria().andEqualTo("deleted",0).andEqualTo("status",1);
            example.orderBy("createTime").desc();
            baseBiz.selectByExample(example);
            return new TableResultResponse<Object>(result.getPages(),result.getResult());
        }
}